<?php defined('SYSPATH') OR die('No direct access allowed.');

class Collection_Controller extends Viewbase_Controller{
	
	public function __construct(){
		
		$this->modelname='collection';
		$this->controllername='collection';	
		
		parent::__construct();	
	}
	
	public function __preprocess_post($model){
		$jsonarray=array();		
		foreach($_POST as $key=>$value){
			$keyelm=split('_', $key);	
			if(count($keyelm)>1){

				echo $keyelm[1].'/';						
				
				echo $keyelm[0];
				echo '<br>';
				
				if($keyelm[1]=='enable'){
					$jsonarray[$keyelm[0]]=array('title'=>$this->input->post($keyelm[0].'_name'));
				}
			}			
		}
		
		$_POST['field_parameters']=json_encode($jsonarray);	
		
		
		if(array_key_exists('has_media', $_POST)){
			$_POST['has_media']=1;
		}else{
			$_POST['has_media']=0;
		}
		
		
		
		return $model;
	}
	
	

	
	
	
	
}